package ruifeng.zcj.dig.ui.shopping.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.Map;

/**
 * Created by Administrator on 2016/10/11 0011.
 */
public class DeatilsAdapter extends BaseAdapter {
    private Context context;
    private Map<String,String> list;
    private ViewHolder viewHolder;


    public DeatilsAdapter(Context context){
        this.context=context;
    }

    public void setList(Map<String,String> list) {
        this.list = list;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
       /* if(convertView==null){
            convertView=LayoutInflater.from(context).inflate(R.layout.home_postslist_lv_item, null);
            viewHolder=new ViewHolder();
            viewHolder.iv_user_ring=(ImageView) convertView.findViewById(R.id.iv_user_ring);
            viewHolder.iv_avatar=(ImageView) convertView.findViewById(R.id.iv_avatar);
            viewHolder.iv_user_rank=(ImageView) convertView.findViewById(R.id.iv_user_rank);

            viewHolder.tv_title=(TextView) convertView.findViewById(R.id.tv_title);
            viewHolder.tv_replys=(TextView) convertView.findViewById(R.id.tv_replys);
            viewHolder.tv_views=(TextView) convertView.findViewById(R.id.tv_views);
            viewHolder.tv_date=(TextView) convertView.findViewById(R.id.tv_date);
            viewHolder.tv_name=(TextView) convertView.findViewById(R.id.tv_name);

            convertView.setTag(viewHolder);
        }else{
            viewHolder=(ViewHolder) convertView.getTag();
        }
        viewHolder.iv_user_ring.setImageResource(image[(int)(Math.random()*6)]);
        viewHolder.iv_avatar.setImageResource(R.drawable.avatar_small);  //添加默认图
        viewHolder.iv_user_rank.setVisibility(View.GONE);

        viewHolder.tv_title.setText(list.get(position).getTitle());
        viewHolder.tv_replys.setText(list.get(position).getReplys());
        viewHolder.tv_views.setText(list.get(position).getViews());
        viewHolder.tv_date.setText(list.get(position).getPosttime());
        viewHolder.tv_name.setText(list.get(position).getUsername());

        bitmapUtils.display(viewHolder.iv_avatar, list.get(position).getAvatar());
*/

        return  convertView;
    }

    static class ViewHolder{
        ImageView iv_user_ring,iv_avatar,iv_user_rank;
        TextView tv_title,tv_replys,tv_views,tv_date,tv_name;
    }
}
